package com.eostoken.eos_wallet.ui.fragmentfactory;

import android.util.SparseArray;

import androidx.fragment.app.Fragment;

import com.eostoken.eos_wallet.ui.fragment.ActiveFragment;
import com.eostoken.eos_wallet.ui.fragment.AddWalletFragment;
import com.eostoken.eos_wallet.ui.fragment.AgencyVoteFragment;
import com.eostoken.eos_wallet.ui.fragment.BackupMnemonicFragment;
import com.eostoken.eos_wallet.ui.fragment.BuyOrSellRamFragment;
import com.eostoken.eos_wallet.ui.fragment.ChangePasswordFragment;
import com.eostoken.eos_wallet.ui.fragment.ConfirmMnemonicFragment;
import com.eostoken.eos_wallet.ui.fragment.CreateAccountFragment;
import com.eostoken.eos_wallet.ui.fragment.ExtractionYieldFragment;
import com.eostoken.eos_wallet.ui.fragment.ImportWalletFragment;
import com.eostoken.eos_wallet.ui.fragment.MiningIndexFragment;
import com.eostoken.eos_wallet.ui.fragment.MiningMortgageFragment;
import com.eostoken.eos_wallet.ui.fragment.MortgageBigFragment;
import com.eostoken.eos_wallet.ui.fragment.MortgageOrRedeemFragment;
import com.eostoken.eos_wallet.ui.fragment.MyStimulateFragment;
import com.eostoken.eos_wallet.ui.fragment.PermissionsViewFragment;
import com.eostoken.eos_wallet.ui.fragment.PrivateKeyFragment;
import com.eostoken.eos_wallet.ui.fragment.ResourceAdministrationFragment;
import com.eostoken.eos_wallet.ui.fragment.StimulateListFragment;
import com.eostoken.eos_wallet.ui.fragment.TransactionDetailsFragment;
import com.eostoken.eos_wallet.ui.fragment.TransferFragment;
import com.eostoken.eos_wallet.ui.fragment.VoteFragment;
import com.eostoken.eos_wallet.ui.fragment.WalletFunctionFragment;

import static com.eostoken.eos_wallet.utils.Constants.ACTIVE;
import static com.eostoken.eos_wallet.utils.Constants.ADD_WALLET;
import static com.eostoken.eos_wallet.utils.Constants.AGENCY_VOTE;
import static com.eostoken.eos_wallet.utils.Constants.BACKUP_MNEMONIC;
import static com.eostoken.eos_wallet.utils.Constants.BUY_SELL_RAM;
import static com.eostoken.eos_wallet.utils.Constants.CHANGE_PASSWORD;
import static com.eostoken.eos_wallet.utils.Constants.CONFIRM_MNEMONIC;
import static com.eostoken.eos_wallet.utils.Constants.CREATE_WALLET;
import static com.eostoken.eos_wallet.utils.Constants.IMPORT_WALLET;
import static com.eostoken.eos_wallet.utils.Constants.MINING_INDEX;
import static com.eostoken.eos_wallet.utils.Constants.MINING_MORTGAGE;
import static com.eostoken.eos_wallet.utils.Constants.MORTGAGE_BIG;
import static com.eostoken.eos_wallet.utils.Constants.MORTGAGE_REDEEM;
import static com.eostoken.eos_wallet.utils.Constants.MY_STIMULATE;
import static com.eostoken.eos_wallet.utils.Constants.MY_STIMULATE_2;
import static com.eostoken.eos_wallet.utils.Constants.PERMISSIONS_VIEW;
import static com.eostoken.eos_wallet.utils.Constants.PRIVATE_KEY;
import static com.eostoken.eos_wallet.utils.Constants.RESOURCE_ADMINISTRATION;
import static com.eostoken.eos_wallet.utils.Constants.STIMULATE_LIST;
import static com.eostoken.eos_wallet.utils.Constants.TRANSACTION;
import static com.eostoken.eos_wallet.utils.Constants.TRANSACTION_DETAILS;
import static com.eostoken.eos_wallet.utils.Constants.VOTE;
import static com.eostoken.eos_wallet.utils.Constants.WALLET_FUNCTION;

public class FragmentFactory {

    private static FragmentFactory mFactory = null;

    public static FragmentFactory getInstatic() {
        if (mFactory == null) {
            mFactory = new FragmentFactory();
        }
        return mFactory;
    }

    public Fragment getFragment(int position) {
        SparseArray<Fragment> map = new SparseArray<Fragment>();
        Fragment fragment = null;
        if (map.get(position, fragment) != null) {
            return map.get(position);
        }
        switch (position) {
            case ADD_WALLET:
                fragment = new AddWalletFragment();
                break;
            case CREATE_WALLET:
                fragment = new CreateAccountFragment();
                break;
            case IMPORT_WALLET:
                fragment = new ImportWalletFragment();
                break;
            case BACKUP_MNEMONIC:
                fragment = new BackupMnemonicFragment();
                break;
            case CONFIRM_MNEMONIC:
                fragment = new ConfirmMnemonicFragment();
                break;
            case ACTIVE:
                fragment = new ActiveFragment();
                break;
            case MY_STIMULATE:
                fragment = new ExtractionYieldFragment();
                break;
            case MINING_INDEX:
                fragment = new MiningIndexFragment();
                break;
            case MINING_MORTGAGE:
                fragment = new MiningMortgageFragment();
                break;
            case MORTGAGE_BIG:
                fragment = new MortgageBigFragment();
                break;
            case MORTGAGE_REDEEM:
                fragment = new MortgageOrRedeemFragment();
                break;
            case AGENCY_VOTE:
                fragment = new AgencyVoteFragment();
                break;
            case BUY_SELL_RAM:
                fragment = new BuyOrSellRamFragment();
                break;
            case CHANGE_PASSWORD:
                fragment = new ChangePasswordFragment();
                break;
            case MY_STIMULATE_2:
                fragment = new MyStimulateFragment();
                break;
            case PERMISSIONS_VIEW:
                fragment = new PermissionsViewFragment();
                break;
            case PRIVATE_KEY:
                fragment = new PrivateKeyFragment();
                break;
            case RESOURCE_ADMINISTRATION:
                fragment = new ResourceAdministrationFragment();
                break;
            case STIMULATE_LIST:
                fragment = new StimulateListFragment();
                break;
            case TRANSACTION_DETAILS:
                fragment = new TransactionDetailsFragment();
                break;
            case TRANSACTION:
                fragment = new TransferFragment();
                break;
            case VOTE:
                fragment = new VoteFragment();
                break;
            case WALLET_FUNCTION:
                fragment = new WalletFunctionFragment();
                break;
        }
        map.put(position, fragment);
        return fragment;
    }
}
